package com.yao.mall.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yao.mall.annotation.AuthCheck;
import com.yao.mall.common.Result;
import com.yao.mall.model.dto.UserSearchRequest;
import com.yao.mall.model.vo.UserVO;
import com.yao.mall.model.vo.WeekOrderCountVO;
import com.yao.mall.service.ShoppingOrderService;
import com.yao.mall.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jiahua.yao
 * @version 1.0
 * @description 统计模块controller
 * @date 2024/5/15 17:05
 */

@RestController
@RequestMapping("/user")
@Slf4j
@Tag(name = "信息统计相关接口")
public class StatisticsController {

    @Resource
    private ShoppingOrderService shoppingOrderService;

    @GetMapping("/getObligationOrder")
    @Operation(summary = "获取待付款订单数")
    @AuthCheck(mustRole = "1")
    public Result<Long> getObligationOrder() {
        Long count = shoppingOrderService.getObligationOrder();
        return Result.success(count);
    }

    @GetMapping("/getDeliverOrder")
    @Operation(summary = "获取待发货订单数")
    @AuthCheck(mustRole = "1")
    public Result<Long> getDeliverOrder() {
        Long count = shoppingOrderService.getDeliverOrder();
        return Result.success(count);
    }

    @GetMapping("/getSumOrder")
    @Operation(summary = "获取总订单数")
    @AuthCheck(mustRole = "1")
    public Result<Long> getSumOrder() {
        Long count = shoppingOrderService.getSumOrder();
        return Result.success(count);
    }

    @GetMapping("/getDayOrder")
    @Operation(summary = "获取当日订单数")
    @AuthCheck(mustRole = "1")
    public Result<Long> getDayOrder() {
        Long count = shoppingOrderService.getDayOrder();
        return Result.success(count);
    }

    @GetMapping("/getWeekOrder")
    @AuthCheck(mustRole = "1")
    @Operation(summary = "过去7天每天的订单数")
    public Result<List<WeekOrderCountVO>> getWeekOrder() {
        List<WeekOrderCountVO> weekOrders = shoppingOrderService.getWeekOrder();
        return Result.success(weekOrders);
    }
}
